package demo.maven.bean;

import demo.maven.bean.factory.BeanFactory;
import demo.maven.bean.service.UserService;
import lombok.extern.slf4j.Slf4j;

/**
 * @author peter
 * @date 2021/12/4 上午2:09
 */
@Slf4j
public class app {
    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) {
            UserService factoryUserService = (UserService) BeanFactory.getFactoryBean("userService");
            // 每次都是新的对象, 多例
            System.out.println(factoryUserService.toString());
            // demo.maven.bean.service.impl.UserServiceImpl@66d2e7d9
            // demo.maven.bean.service.impl.UserServiceImpl@1efbd816
            // demo.maven.bean.service.impl.UserServiceImpl@6a2bcfcb
        }

        for (int i = 0; i < 3; i++) {
            UserService singleUserService = (UserService) BeanFactory.getSingletonBean("userService");
            // 每次都是新的对象, 多例
            System.out.println(singleUserService.toString());
            // demo.maven.bean.service.impl.UserServiceImpl@4de8b406
            // demo.maven.bean.service.impl.UserServiceImpl@4de8b406
            // demo.maven.bean.service.impl.UserServiceImpl@4de8b406
        }

    }
}
